package com.sven.hello.filter.post

import com.netflix.zuul.ZuulFilter
import com.netflix.zuul.context.RequestContext
import org.slf4j.Logger
import org.slf4j.LoggerFactory

import javax.servlet.http.HttpServletResponse

class PostFilter extends ZuulFilter {
    Logger logger = LoggerFactory.getLogger(PostFilter.class);

    @Override
    String filterType() {
        return "post";
    }

    @Override
    int filterOrder() {
        return 1000
    }

    @Override
    boolean shouldFilter() {
        return true;
    }

    @Override
    Object run() {
        logger.info("---PostFilter---this is a post filter : receive response");
        HttpServletResponse response = RequestContext.getCurrentContext().getResponse();
        response.getOutputStream().print(", i am PostFilter");
        response.flushBuffer();
    }
}
